package demo;

public class Test {

    public static void main(String[] args) {
        System.out.println(isPalindrome("abcfcba"));
        System.out.println(isPalindrome("abfgba"));
        System.out.println(isPalindrome("a ba"));
        System.out.println(isPalindrome(" abba "));
        System.out.println(isPalindrome("躺一躺"));
    }

    public static boolean isPalindrome(String s) {
        int front = 0;
        int rear = s.length()-1;
        while(front < rear) {
            if(s.charAt(front) != s.charAt(rear)) {
                return false;
            }else {
                front++;
                rear--;
            }
        }
        return true;
    }
}
